////////////////////////////////////////////////////////////////////////////////
///////// Inflexibility and Corporate Credit Spreads ///////////////////////////
///////// Zhe An, Abe de Jong, Ying Xia, Zhaofeng Xu ///////////////////////////
////////////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////////////
* Date: May 5, 2025
* This do file contains code generating results for Tables 4 to 10
* Please define the path for datasets and the path for storing results before running the following program. 
////////////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////////////

********************************************************************************
* Table 4 Contraction Inflexibility Versus Expansion Inflexibility
********************************************************************************

* Use the additional test sample 
* [Additional_test_sample]

use "Path\Additional_test_sample.dta", clear

* Model 1
reghdfe credit_spread  c.inflex20##c.high_bm  long_term_debt operating tot_debt int_cov1 int_cov2 int_cov3 ret_bps ret_var_percent c_rating  neg_VaR_5_percent illiq, absorb(issue_id qtr)  cluster(GVKEY year)
estimates store a1, title(Model 1)

* Model 2
reghdfe credit_spread c.inflex20##c.dbm3 c.inflex20##c.dbm3_2 long_term_debt operating tot_debt int_cov1 int_cov2 int_cov3 ret_bps ret_var_percent c_rating  neg_VaR_5_percent illiq, absorb(issue_id qtr)  cluster(GVKEY year)
estimates store a2, title(Model 1)

* Model 3
reghdfe credit_spread c.inflex20##c.ot_ind_down long_term_debt operating tot_debt int_cov1 int_cov2 int_cov3 ret_bps ret_var_percent c_rating  neg_VaR_5_percent illiq ,absorb(issue_id qtr)  cluster(GVKEY year )
estimates store a3, title(Model 1)

* Model 4
reghdfe credit_spread c.inflex20##c.dindsales1 c.inflex20##c.dindsales2  long_term_debt operating tot_debt int_cov1 int_cov2 int_cov3 ret_bps ret_var_percent c_rating neg_VaR_5_percent illiq,absorb(issue_id qtr)  cluster(GVKEY year)
estimates store a4, title(Model 1)

esttab a1 a2 a3 a4 using "Path\Table_4.csv", b(3) t(3) scalars(r2 r2_a ) plain  replace nogaps
est clear


********************************************************************************

********************************************************************************
* Table 5 Cash Flow Volatility
********************************************************************************

* Use the additional test sample 
* [Additional_test_sample]

use "Path\Additional_test_sample.dta", clear

* Models 1 to 2
local  list_indep = "std_cf_perc12  std_cf_perc20"

foreach my_indep in `list_indep'{
reghdfe  credit_spread c.inflex20##c.`my_indep'  long_term_debt operating tot_debt int_cov1 int_cov2 int_cov3 ret_bps ret_var_percent c_rating neg_VaR_5_percent illiq  , absorb(issue_id qtr)  cluster(GVKEY year)
estimates 	store `my_indep'
}
esttab std_cf_perc12  std_cf_perc20 using "Path\Table_5.csv", b(3) t(3) scalars(r2 r2_a ) plain replace nogaps
est clear


********************************************************************************

********************************************************************************
* Table 6 Financial Distress Risk
********************************************************************************

* Use the additional test sample 
* [Additional_test_sample]

use "Path\Additional_test_sample.dta", clear

* Models 1 to 3
local  list_indep = " altman_z zm edf"

foreach my_indep in `list_indep'{
reghdfe  credit_spread c.inflex20##c.`my_indep'  long_term_debt operating tot_debt int_cov1 int_cov2 int_cov3 ret_bps ret_var_percent c_rating neg_VaR_5_percent illiq  , absorb(issue_id qtr)  cluster(GVKEY year)
estimates 	store `my_indep'
}
esttab  altman_z zm edf using "Path\Table_6.csv", b(3) t(3) scalars(r2 r2_a ) plain   replace nogaps
est clear

********************************************************************************

********************************************************************************
* Table 7 Bond Characteristics
********************************************************************************

* Use the additional test sample 
* [Additional_test_sample]

use "Path\Additional_test_sample.dta", clear

* Model 1 to 3
local  list_indep = "vari_rating time_to_mtu issuance_maturity"

foreach my_indep in `list_indep'{
reghdfe  credit_spread c.inflex20##c.`my_indep' long_term_debt operating tot_debt int_cov1 int_cov2 int_cov3 ret_bps ret_var_percent c_rating neg_VaR_5_percent illiq  , absorb(issue_id qtr)  cluster(GVKEY year)
estimates 	store `my_indep'
}
esttab  vari_rating time_to_mtu issuance_maturity using "Path\Table_7.csv", b(3) t(3) scalars(r2 r2_a ) plain   replace nogaps
est clear


********************************************************************************

********************************************************************************
* Table 8 Additional Controls
********************************************************************************

* Use the additional test sample 
* [Additional_test_sample]

use "Path\Additional_test_sample.dta", clear

* Model 1 to 4
local  list_indep = " neg_cost_sticky   redeploy  irreversibility"

reghdfe credit_spread inflex20 qfc std_qfc long_term_debt operating tot_debt int_cov1 int_cov2 int_cov3 ret_bps ret_var_percent c_rating neg_VaR_5_percent illiq , absorb(issue_id qtr)  cluster(GVKEY year)
estimates store op_lev, title(Model 1)

foreach my_indep in `list_indep'{
reghdfe  credit_spread inflex20 `my_indep'  long_term_debt operating tot_debt int_cov1 int_cov2 int_cov3 ret_bps ret_var_percent c_rating neg_VaR_5_percent illiq , absorb(issue_id qtr)  cluster(GVKEY year)
estimates 	store `my_indep'
}

esttab op_lev neg_cost_sticky  redeploy  irreversibility using "Path\Table_8.csv", b(3) t(3) scalars(r2 r2_a ) plain  replace nogaps
est clear


********************************************************************************

********************************************************************************
* Table 9 Alternative Inflexibility Measure 
********************************************************************************

* Use the alternative measure sample 
* [Alternative_measure_sample]

use "Path\Alternative_measure_sample.dta", clear

* Model 1 to 3
local  list_indep = "high_inflex inflex5_20 inflex_infi "

foreach my_indep in `list_indep'{
reghdfe  credit_spread  `my_indep' long_term_debt operating tot_debt int_cov1 int_cov2 int_cov3 ret_bps ret_var_percent c_rating neg_VaR_5_percent illiq  , absorb(issue_id qtr)  cluster(GVKEY year)
estimates 	store `my_indep'
}
esttab high_inflex inflex5_20 inflex_infi  using "Path\Table_9a.csv", b(3) t(3) scalars(r2 r2_a ) plain  replace nogaps
est clear

* Use the non-overlap sample 
* [Non_overlap_sample]

use "Path\Non_overlap_sample.dta", clear

*Model 4
reghdfe credit_spread non_overlap_inflex long_term_debt operating tot_debt int_cov1 int_cov2 int_cov3 ret_bps ret_var_percent c_rating neg_VaR_5_percent illiq , absorb(issue_id year)  cluster(GVKEY year)
estimates store non_overlap, title(Model 1)

esttab non_overlap using "Path\Table_9b.csv", b(3) t(3) scalars(r2 r2_a ) plain   replace nogaps

********************************************************************************

********************************************************************************
* Table 10 Inflexibility and Issuance Credit Spreads
********************************************************************************

* Use the issuance sample 
* [Issuance_sample]

use "Path\Issuance_sample.dta", clear

* Model 1
reghdfe issue_spread inflex20 long_term_debt operating tot_debt int_cov1 int_cov2 int_cov3 ret_bps ret_var_percent c_rating  neg_VaR_5_percent illiq , absorb(SIC qtr)  cluster(GVKEY year)
estimates store issue1, title(Model 1)

esttab  issue1 using "Path\Table_10.csv", b(3) t(3) scalars(r2 r2_a ) plain  replace nogaps
est clear


********************************************************************************

////////////////////////////////////////////////////////////////////////////////
* The above codes generate the result, and the format of table is finalised in Excel. 

////////////////////////////////////////////////////////////////////////////////

